package com.util;

import java.util.Timer;
import java.util.TimerTask;

import org.apache.commons.mail.DefaultAuthenticator;
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

public class TimerEmail
{
	public void sendEmail()
	{
		Email email = new SimpleEmail();
		email.setHostName("smtp.sina.com.cn");
		email.setAuthenticator(new DefaultAuthenticator("dingna0829@sina.com", "15849930743"));
		email.setTLS(true);
		try
		{
			email.setFrom("dingna0829@sina.com");
			email.setSubject("TestMail");
			email.setSSL(true);
			email.setMsg("This is a test mail ... :-)");
			email.addTo("zhigao11@hh.se");
			email.send();
		}
		catch (EmailException e)
		{
			e.printStackTrace();
		}
	}
	
	public void send()
	{
		Timer t = new Timer();
		
		TimerTask task = new TimerTask()
		{
			
			@Override
			public void run()
			{
				
			}
			
		};

		
		t.schedule(task, 24 * 60 * 60 * 1000);
	}
	
	public static void main(String[] args)
	{
		new TimerEmail().sendEmail();
		System.out.println("scasd");
	}
}
